<?php

use yii\helpers\Html;
use yii\grid\GridView;
use mdm\admin\components\Helper;
use backend\assets\AppAsset;
use common\models\agentUser\AgentUser;

/* @var $this yii\web\View */
/* @var $searchModel mdm\admin\models\searchs\User */
/* @var $dataProvider yii\data\ActiveDataProvider */

AppAsset::register($this);
$this->title = Yii::t('app', '代理人员管理');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?=
    GridView::widget([
            'dataProvider' => $dataProvider,
            'columns' => [
                ['class' => 'yii\grid\SerialColumn'],
                'id',
                'user_id',
                'mobile',
                'created_at:date',
                [
                    'class'     => 'yii\grid\ActionColumn',
                    'header'    => '操作',
                    'template'  => '{view}{leave-post}{close-account}',
                    'buttons'   => [
                        'view'  => function($url,$model){
                            return Html::a('查看',$url,[
                                'class'     => 'btn btn-view',
                            ]);
                        },
                        'leave-post' => function($url,$model){
                            return Html::a(AgentUser::$agencyStatus[$model->agency_status],null,[
                                'class'     => 'btn btn-leave-post',
                                'onclick'   => "leave_post(this)",
                                'id'        => $model->id,
                                'status'    => $model->agency_status,
                            ]);
                        },
                        'close-account' => function($url,$model){
                            return Html::a(AgentUser::$agencyStatus[AgentUser::AGENCY_STATUS_BAN],$url,[
                                'class'     => 'btn btn-close-account',
                            ]);
                        },
                    ]
                ],
            ],
        ]);
    ?>
</div>